﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotaHelp.Models;
using System.Diagnostics;
using System.IO;

namespace DotaHelp.Helpers
{
	public class LogingHelper
	{
		public static void LogException(HttpRequestBase request, Exception ex)
		{
			Log(request.RequestContext.HttpContext.Server, request.Url.ToString() + "|" + ex.ToString() + "\r\n\r\n");
			try
			{
				using (var db = new DotaModel())
				{
					db.WriteError(request.Url.ToString() + "|" + ex.ToString());
				}
			}
			catch (Exception)
			{

			}
		}
		
		public static void LogException(HttpRequest request, Exception ex)
		{
			Log(request, request.Url.ToString() + "|" + ex.ToString() + "\r\n\r\n");
			try
			{
				using (var db = new DotaModel())
				{
					db.WriteError(request.Url.ToString() + "|" + ex.ToString());
				}
			}
			catch (Exception)
			{

			}
		}

		static object Dummy = new object();
		public static void Log(HttpServerUtility Server, string message)
		{
			/*lock (Dummy)
			{
				File.AppendAllText(Server.MapPath("~/log.txt"), message + "\r\n");
			}*/
		}

		public static void Log(HttpServerUtilityBase Server, string message)
		{
			/*lock (Dummy)
			{
				File.AppendAllText(Server.MapPath("~/log.txt"), message + "\r\n");
			}*/
		}

		public static void Log(HttpRequest request, string message)
		{
			/*lock (Dummy)
			{
				File.AppendAllText(request.MapPath("~/log.txt"), message + "\r\n");
			}*/
		}
	}
}